from django.contrib import admin
from .models import UserWebpage

@admin.register(UserWebpage)
class UserWebpageAdmin(admin.ModelAdmin):
    list_display = ('id', 'user', 'content_preview')
    search_fields = ('user',)
    
    def content_preview(self, obj):
        if len(obj.content) > 50:
            return obj.content[:50] + "..."
        return obj.content
    content_preview.short_description = '内容预览'
    
    fields = ('user', 'content')
# Register your models here.
